home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok80.lha
/
CheckCaps
/
DeviceSupport.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
2KB
|
68 lines
(*---------------------------------------------------------------------------
:Program. DeviceSupport.mod
:Contents. Easy Device access
:Author. Christian Stiens
:Address. Snail-Mail: E-Mail:
:Address. Heustiege 2 UUCP: Christian_Stiens@ouzonix.bo.open.de
:Address. W-4710 Lüdinghausen FIDO: 2:241/5807
:Copyright. public domain
:Language. Oberon
:Translator. Amiga Oberon v2.42d (inofficial beta version)
:History. V1.0, 10-May-92
---------------------------------------------------------------------------*)
MODULE DeviceSupport;
IMPORT
e: Exec, es: ExecSupport;
TYPE
InitProc* = PROCEDURE(ioReq: e.MessagePtr);
PROCEDURE OpenDev* (name : ARRAY OF CHAR;
unit : LONGINT;
flags : LONGSET;
ioSize : INTEGER;
ioInit : InitProc): e.MessagePtr; (* $CopyArrays- *)
VAR
port: e.MsgPortPtr;
ioReq: e.IORequestPtr;
BEGIN
port := es.CreatePort("",0);
IF port = NIL THEN RETURN NIL END;
IF ioSize = 0 THEN ioSize := SIZE(e.IOStdReq) END;
ioReq := es.CreateExtIO(port,ioSize);
IF ioReq = NIL THEN es.DeletePort(port); RETURN NIL END;
IF ioInit # NIL THEN ioInit(ioReq) END;
IF e.OpenDevice(name,unit,ioReq,flags) # 0 THEN
es.DeleteExtIO(ioReq);
es.DeletePort(port);
RETURN NIL
END;
RETURN ioReq;
END OpenDev;
PROCEDURE CloseDev* (ioReq: e.MessagePtr);
VAR port: e.MsgPortPtr;
BEGIN
port := ioReq.replyPort;
e.CloseDevice(ioReq);
es.DeleteExtIO(ioReq);
es.DeletePort(port);
END CloseDev;
PROCEDURE DoCommand* (ioReq: e.MessagePtr; cmd: INTEGER);
BEGIN
ioReq(e.IORequest).command := cmd;
e.OldDoIO(ioReq);
END DoCommand;
END DeviceSupport.